//
//  Primer_Protocol_Demo1VC.swift
//  APSwift
//
//  Created by jianbo.pei on 2022/11/11.
//

import UIKit

/// 《Swift入门 - 协议》001 - CustomStringConvertible和CustomDebugStringConvertible
class Primer_Protocol_Demo1VC: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        test1()
        test2()
    }
    
    private func test1() {
        let p1 = PP_Protocol_CSC_Person1(name: "AbnerPei", job: "iOS开发", age: 18)
        print("p1 is :")
        print(p1)
        
        let p2 = PP_Protocol_CSC_Person2(name: "jianbo.pei", job: "程序员", age: 18)
        print("p2 is :")
        print(p2)
        
        debugPrint(p2)
        
        /**
         p1 is :
         PP_Protocol_CSC_Person1(name: "AbnerPei", job: "iOS开发", age: 18)
         p2 is :
         主人，18岁做程序员工作的jianbo.pei来电话了
         主人，18岁做程序员工作的jianbo.pei来电话了
         */
    }
    
    private func test2() {
        
        let p = PP_Protocol_CSC_Person3(name: "jianbo.pei", job: "程序员", age: 18)
        print("p is :")
        print(p)
        
        debugPrint(p)
        
        /**
         p is :
         主人，18岁做程序员工作的jianbo.pei来电话了
         DEBUG 主人，18岁做程序员工作的jianbo.pei来电话了
         */
    }

}


struct PP_Protocol_CSC_Person1 {
    var name: String
    var job: String
    var age: Int
}

struct PP_Protocol_CSC_Person2: CustomStringConvertible {
    var name: String
    var job: String
    var age: Int
    
    var description: String {
        return "主人，\(age)岁做\(job)工作的\(name)来电话了"
    }
}

struct PP_Protocol_CSC_Person3: CustomStringConvertible, CustomDebugStringConvertible {
    var name: String
    var job: String
    var age: Int
    
    var description: String {
        return "主人，\(age)岁做\(job)工作的\(name)来电话了"
    }
    
    var debugDescription: String {
        return "DEBUG 主人，\(age)岁做\(job)工作的\(name)来电话了"
    }
}
